#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=800000;

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  static int fa[maxn+1];
  static char c[maxn+1], s[maxn*10+1];
  int n;
  scanf("%d", &n);
  for (int i=2; i<=n; i++) {
    scanf("%d %c ", fa+i, c+i);
  }
  scanf(" %s ", s);

  int ans=0;
  for (int i=0; s[i]!='\0'; i++) {
    for (int j=2; j<=n; j++) {
      for (int x=i, y=j; x>=0 && y>1 && s[x]==c[y]; x--, y=fa[y]) {
	ans++;
      }
    }
  }
  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
